package com.yanqu.road.entity.wingroom.message;

import com.yanqu.road.entity.DataObject;

import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author ：zfr
 * @date ：2022/3/17 23:26
 */
public class WingRoomMessageDetailInfo extends DataObject {
    private long userId;
    private int messageSwitch;
    private String selfMessageContent = "";
    private long selfMessageGiveLikeTimes;
    private Map<Long, GuestMessage> guestMessageMap = new ConcurrentHashMap<>();
    private long lastAccessTime; //最后访问时间
    private long ownerLastRequestTime;  //玩家自己打开留言板的最后时间
    private long maxMessageId;

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public int getMessageSwitch() {
        return messageSwitch;
    }

    public void setMessageSwitch(int messageSwitch) {
        if (this.messageSwitch != messageSwitch) {
            this.messageSwitch = messageSwitch;
            setUpdateOption();
        }
    }

    public String getSelfMessageContent() {
        return selfMessageContent;
    }

    public void setSelfMessageContent(String selfMessageContent) {
        if (!Objects.equals(selfMessageContent, this.selfMessageContent)) {
            this.selfMessageContent = selfMessageContent;
            setUpdateOption();
        }
    }

    public long getSelfMessageGiveLikeTimes() {
        return selfMessageGiveLikeTimes;
    }

    public void setSelfMessageGiveLikeTimes(long selfMessageGiveLikeTimes) {
        if (this.selfMessageGiveLikeTimes != selfMessageGiveLikeTimes) {
            this.selfMessageGiveLikeTimes = selfMessageGiveLikeTimes;
            setUpdateOption();
        }
    }

    public Map<Long, GuestMessage> getGuestMessageMap() {
        return guestMessageMap;
    }

    public void setGuestMessageMap(Map<Long, GuestMessage> guestMessageMap) {
        this.guestMessageMap = guestMessageMap;
    }

    public long getLastAccessTime() {
        return lastAccessTime;
    }

    public void setLastAccessTime(long lastAccessTime) {
        if (this.lastAccessTime != lastAccessTime) {
            this.lastAccessTime = lastAccessTime;
            setUpdateOption();
        }
    }

    public long getOwnerLastRequestTime() {
        return ownerLastRequestTime;
    }

    public void setOwnerLastRequestTime(long ownerLastRequestTime) {
        if (this.ownerLastRequestTime != ownerLastRequestTime) {
            this.ownerLastRequestTime = ownerLastRequestTime;
            setUpdateOption();
        }
    }

    public long getNextMessageId() {
        setMaxMessageId(maxMessageId + 1);
        return maxMessageId;
    }

    public void putMessage(GuestMessage message) {
        guestMessageMap.put(message.getMessageId(), message);
        setUpdateOption();
    }

    public long getMaxMessageId() {
        return maxMessageId;
    }

    public void setMaxMessageId(long maxMessageId) {
        if (this.maxMessageId != maxMessageId) {
            this.maxMessageId = maxMessageId;
            setUpdateOption();
        }
    }
}
